<?php
include '../config.php';
include '../functions.php';
include '../includes/classes/conexao.class.php';
$bd = 'gw';
$conexao = new Conexao($bd);
if ($_SERVER['REQUEST_METHOD'] == 'GET') { 
	echo "GET";
} else {
	$area = strip_tags($_POST["txt_area"]);
	$pai = strip_tags($_POST["cbo_pai"]);

	$sql = "INSERT INTO public.areas(descricao, pai) ";
	$sql .= "VALUES ( ";
	$sql .= "'$area', ";
	$sql .= "$pai )";

	$conexao->Executar($sql);
	
	$sql = "SELECT id, descricao FROM public.areas WHERE id = (SELECT max(id) FROM public.areas)";
	$conexao->Executar($sql);
	if($conexao->ContarLinhas() > 0 ) {
		while ($row = $conexao->MostrarResultados()) {
			$ultima_area = $row[0];
			$area_nova = $row[1];
		}
	}	
	echo "<tr>
		<td>$ultima_area</td>
		<td><a href='#' title='Editar entrada' class='edita' id='$ultima_area'>$area_nova</a></td>
		</tr>";

}
?>